﻿using System;
using System.Collections.Generic;
using System.Text;

using MapCenterSystem.DefineType;

namespace MapCenterSystem.DataInfo
{
    public class GraphNodeInfoEx: GraphNodeInfo, IComparable<GraphNodeInfoEx>
    {
        public int IDStreet;
        GraphNodeInfoEx father = null;
        float h = 0;
        public float H
        {
            get { return h; }
            set { h = value; }
        }
        float f = 0;
        public float F
        {
            get { return f; }
            set { f = value; }
        }
        float g = 0;
        public float G
        {
            get { return g; }
            set { g = value; }
        }

        public void CalculateHeuristic(GraphNodeInfoEx end)
        {
            h = (float)Coordinate.Distance(location, end.location);
        }

        public GraphNodeInfoEx()
        {
        }

        public GraphNodeInfoEx Father
        {
            get { return father; }
            set { father = value; }
        }

        public GraphNodeInfoEx(GraphNodeInfoEx node)
        {            
            this.Id = node.Id;
            this.IsRoot = node.IsRoot;
            this.Length = node.Length;
            this.Location = node.Location;
            this.Parent = node.Parent;

            this.IDStreet = node.IDStreet;
            this.Father = node.Father;
            this.h = node.h;
            this.g = node.g;
            this.f = node.f;
        }


        public override bool Equals(object obj)
        {
            GraphNodeInfoEx node = (GraphNodeInfoEx)obj;
            if (node.Location.Equals(this.Location))
                return true;
            return false;
        }



        #region IComparable<GraphNodeInfoEx> Members

        public int CompareTo(GraphNodeInfoEx other)
        {
            if (other.f == this.f)
                return 0;
            if (other.f < this.f)
                return 1;
            return -1;
        }

        #endregion
    }
}
